import axios from 'axios';
import { loginreq, req } from './axiosFun';


//获取当前页面的操作权限(
export const UserOpRight = (params) => { return req("post", "/api/User/page/opRight", params) };


// 登录接口
export const login = (params) => { return loginreq("post", "/api/login", params) };
//注册用户
export const register = (params) => { return loginreq("post", "/api/register", params) };
//获取验证码
export const getCode = (params) => { return req("get", "/api/img/identifyImage?time="+new Date().getTime(), params) };

// 获取用户菜单
export const menu = (params) => { return req("get", "/api/menu/" + localStorage.getItem('userdata')) };
// 退出接口
export const loginout = () => { return req("delete","/api/loginOut" ).then(res => res.data) };

/**
 * 用户管理
 **/
// 用户管理-获取用户列表
export const userList = (params) => { return req("post", "/api/User/list", params) };
// 用户管理-保存（添加编辑）
export const userSave = (params) => { return req("post", "/api/User/save", params) };
// 用户管理-删除用户
// export const userDelete = (params) => { return axios.delete("/api/User/delete?ids=" + params + "&token=" + localStorage.getItem('userdata')).then(res => res.data) };
export const userDelete = (params) => { return req("delete","/api/User/delete/" + params ).then(res => res.data) };

// 用户管理-重置密码
export const userPwd = (params) => { return req("post", "/api/User/pwd", params) };
// 用户管理-修改状态
// export const userLock = (params) => { return axios.get("/api/User/lock?userId=" + params.userId + "&lock=" + params.lock + "&token=" + localStorage.getItem('userdata')) };
export const userLock = (params) => { return req("post","/api/User/lock" , params) };

// 用户管理-数据权限
// export const UserDeptTree = (params) => { return axios.get("/api/User/right/tree/" + params + "?token=" + localStorage.getItem('userdata')) };
export const UserRightTree = (params) => { return req("get","/api/User/right/tree/" + params ) };

// 用户管理-数据权限保存
// export const UserDeptSave = (params) => { return req("post", "/api/User/right/save", params) };

// 用户管理-获取部门设置
// export const UserDeptdeptTree = (params) => { return axios.get("/api/UserDept/deptTree/" + params + "?token=" + localStorage.getItem('userdata')) };
export const UserDeptTree = () => { return req("get","/api/User/Dept/list" ) };

// 用户管理-保存部门设置
export const UserChangeDept = (params) => { return req("post", "/api/User/Dept/save", params) };
// 用户管理-用户下线
export const userExpireToken = (params) => { return req("get", "/api/User/expire/" + params) };
// 用户管理-刷新缓存
export const userFlashCache = (params) => { return req("get", "/api/User/flashCache/" + params, {}) };
//用户管理-查询所有的角色信息
export const UserGetrole = () => { return req("post", "/api/User/role/list") };
// 用户管理-配置角色
export const UserRole = (params) => { return req("post", "/api/User/role/save", params) };


/**
 * 菜单管理
 **/
// 菜单管理-获取菜单Module/list
export const ModuleList = () => { return req("post", "/api/Module/list") };
// 菜单管理-根据菜单获取数据
// export const ModuleGet = (params) => { return axios.get("/api/Module/get/" + params + "?token=" + localStorage.getItem('userdata')) };
export const ModuleGet = (params) => { return req("get","/api/Module/get/" + params) };

// 菜单管理-获取父级菜单Module/nodes
export const ModuleNodes = (params) => { return req("post", "/api/Module/nodes", params) };
// 菜单管理-修改菜单
export const ModuleSave = (params) => { return req("post", "/api/Module/save", params) };
// 菜单管理-删除菜单
export const ModuleDelete = (params) => { return req("delete","/api/Module/delete/" + params).then(res => res.data) };
//获取图标
export const ModuleIcon = () => { return req("get", "/api/Module/icon") };
//获取图标url
export const ModuleIconUrl = (params) => { return req("get", "/api/Module/url/"+params) };



/**
 * 角色管理
 **/
// 角色管理-获取角色列表
export const roleList = (params) => { return req("post", "/api/Role/list", params) };
// 角色管理-保存（添加编辑）
export const roleSave = (params) => { return req("post", "/api/Role/save", params) };
// 角色管理-删除角色
// export const roleDelete = (params) => { return axios.delete("/api/Role/delete?ids=" + params + "&token=" + localStorage.getItem('userdata')).then(res => res.data) };
export const roleDelete = (params) => { return req("delete","/api/Role/delete/" + params) };

// 角色管理-菜单权限（获取）
// export const RoleRightTree = (params) => { return axios.get("/api/Role/tree/" + params + "?token=" + localStorage.getItem('userdata')) };
export const RoleRightTree = (params) => { return req("get","/api/Role/tree/" + params) };

// 角色管理-菜单权限（保存）
export const RoleRightSave = (params) => { return req("post", "/api/Role/tsave", params) };

/**
 * 部门管理
 **/
// 部门管理-获取部门列表
export const deptList = (params) => { return req("post", "/api/Dept/list", params) };
// 部门管理-保存（添加编辑）
export const deptSave = (params) => { return req("post", "/api/Dept/save", params) };
// 部门管理-删除部门
// export const deptDelete = (params) => { return axios.get("/api/Dept/delete?ids=" + params + "&token=" + localStorage.getItem('userdata')).then(res => res.data) };
export const deptDelete = (params) => { return req("get","/api/Dept/delete/" + params ).then(res => res.data) };

/**
 * 系统环境变量
 **/
// 系统环境变量-获取系统环境变量列表
export const variableList = (params) => { return req("post", "/api/Variable/list", params) };
// 系统环境变量-保存（添加编辑）
export const variableSave = (params) => { return req("post", "/api/Variable/save", params) };
// 系统环境变量-删除系统环境变量
export const variableDelete = (params) => { return req("delete","/api/Variable/delete/"+params).then(res => res.data) };

/**
 * 权限管理
 **/
// 权限管理-获取权限列表
export const rightList = (params) => { return req("post", "/api/Permission/list", params) };
// 权限管理-保存权限
export const rightSave = (params) => { return req("post", "/api/Permission/save", params) };
// 权限管理-删除权限
// export const ermissionDelete = (params) => { return axios.delete("/api/Permission/delete?ids=" + params + "&token=" + localStorage.getItem('userdata')).then(res => res.data) };
export const rightDelete = (params) => { return req("delete","/api/Permission/delete/" + params) };

// 权限管理-配置权限
export const Roleright = (params) => { return req("post", "/api/Permission/cnf", params) };

// 权限管理-获取角色数据
// export const roleDropDown = () => { return axios.get("/api/Role/dropDown/all?&token=" + localStorage.getItem('userdata')).then(res => res.data) };
export const getRole=() => { return req("get", "/api/Permission/role/list") };

